const nodemailer = require("nodemailer")

// 发送邮件通知
async function sendEmail (name, email, content) {
  try {
    const user = '1737770335@qq.com'
    let transporter = nodemailer.createTransport({
      host: 'smtp.qq.com',
      secure: false,
      port: 587,
      auth: {
        user: user, //  发件人邮箱
        pass: 'darqwixztqxdbejd' //  从qq邮箱中获取授权码
      }
    })
    return await transporter.sendMail({
      from: `Yrainly <${user}>`, // sender address
      to: email, // list of receivers
      subject: name, // Subject line
      text: name, // plain text body
      html: `<b>${content}</b>` // html body
    })
  } catch (error) {
    throw error
  }
}

sendEmail('通知', '651250336@qq.com', '测试')